<template>
  <div>
    <div v-if="data.images.length>=3" class="moreimg">
      <div class="hand" @click="$router.push('/post/detail?id='+data.id)">
        <div class="title" :title="data.title">{{data.title}}</div>
        <p v-html="data.summary"></p>
        <div class="img">
          <img :src="data.images[0]" alt />
          <img :src="data.images[1]" alt />
          <img :src="data.images[2]" alt />
        </div>
      </div>
      <div class="footer">
        <div class="left">
          <i class="el-icon-location-outline"></i>
          <span>{{data.cityName}}</span>
          <span>by</span>
          <div class="user">
            <img :src="$axios.defaults.baseURL + data.account.defaultAvatar" alt />
            <span>{{data.account.nickname}}</span>
          </div>
          <i class="el-icon-view"></i>
          <span>{{data.watch||0}}</span>
        </div>
        <div class="right">
          <div>
            <span>{{data.like||0}}</span> 赞
          </div>
        </div>
      </div>
    </div>
    <div v-else class="oneimg">
      <div class="left">
        <img :src="data.images[0]" alt />
      </div>
      <div class="right">
        <div class="hand" @click="$router.push('/post/detail?id='+data.id)">
          <div class="title" :title="data.title">{{data.title}}</div>
          <p v-html="data.summary"></p>
        </div>
        <div class="info">
          <div class="info_l">
            <i class="el-icon-location-outline"></i>
            <span>{{data.cityName}}</span>
            <span>by</span>
            <div class="user">
              <img :src="$axios.defaults.baseURL + data.account.defaultAvatar" alt />
              <span>{{data.account.nickname}}</span>
            </div>
            <i class="el-icon-view"></i>
            <span>{{data.watch||0}}</span>
          </div>
          <div class="info_r">
            <span>{{data.like||0}}</span> 赞
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props:{
    data:Object
  }
}
</script>
<style lang="less" scoped>
a {
  text-decoration: none;
}
.moreimg {
  padding-bottom: 15px;
  border-bottom: 1px solid #ddd;
  .hand {
    cursor: pointer;
  }
  .title {
    font-size: 20px;
    padding: 15px 0;
    color: #000;
    &:hover {
      color: #ffa500;
    }
  }
  p {
    font-size: 14px;
    color: #555;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
  }
  .img {
    display: flex;
    padding: 15px 0;
    img {
      width: 220px;
      height:150px;
      flex: 1;
      object-fit: cover;
      &:not(:first-child) {
        margin-left: 11px;
      }
    }
  }
  .footer {
    display: flex;
    justify-content: space-between;
    .left {
      font-size: 12px;
      color: #888;
      display: flex;
      align-items: center;
      span {
        margin: 0 5px;
      }
      img {
        width: 20px;
        height: 20px;
        object-fit: cover;
        border-radius: 50%;
      }
      .user {
        margin: 0 5px;
        span {
          color: #ffa500;
        }
      }
    }
    .right {
      color: #ffa500;
    }
  }
}
.oneimg {
  padding: 15px 0;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #ddd;
  .left {
    img {
      cursor: pointer;
      width: 220px;
      height: 150px;
      object-fit: cover;
    }
  }
  .right {
    flex: 1;
    padding: 0 10px;
    .hand {
      cursor: pointer;
    }
    .title {
      font-size: 20px;
      &:hover {
        color: #ffa500;
      }
    }
    p {
      margin: 15px 0;
      font-size: 14px;
      height: 63px;
      line-height: 1.5;
      color: #555;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 3;
      -webkit-box-orient: vertical;
    }
    .info {
      display: flex;
      justify-content: space-between;
      .info_l {
        display: flex;
        align-items: center;
        color: #888;
        font-size: 14px;
        span {
          margin: 0 5px;
        }
        .user {
          img {
            width: 20px;
            height: 20px;
            object-fit: cover;
            border-radius: 50%;
          }
        }
      }
      .info_r {
        color: #ffa500;
      }
    }
  }
}
</style>